<?php
/**
 * common model file Created by PhpStorm.
 * User: wumengmeng
 * Date: 2019/09/03
 * Time: 15:20
 */

namespace HiCommon\Model;


class RoadRescue extends Base
{

    protected $table = 'road_rescue';

    protected $guarded = [];

    //public $timestamps = false;

    /**
     * 应该被调整为日期的属性
     *
     * @var array
     */
    protected $dates = [
    ];

    /**
     * 获取状态对应的名称
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getStateAttribute($value)
    {
        switch ($value)
        {
            case 0:
                $res = ['id'=>0,'name'=>'草稿'];
                break;
            case 1:
                $res = ['id'=>1,'name'=>'待审核'];
                break;
            case 2:
                $res = ['id'=>2,'name'=>'通过'];
                break;
            case 3:
                $res = ['id'=>3,'name'=>'拒绝'];
                break;
            default:
                $res = ['id'=>-1,'name'=>'未知'];
        }
        return $res;
    }


    /**
     * 类型
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getTypeAttribute($value)
    {
        switch ($value)
        {
            case 1:
                $res = ['id'=>1,'name'=>'2*2（正方向）'];
                break;
            case 2:
                $res = ['id'=>2,'name'=>'2*1（长方向）'];
                break;
            default:
                $res = ['id'=>-1,'name'=>'未知'];
        }
        return $res;
    }



    /**
     * 获取图片可用链接
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getImgAttribute($value)
    {
        $arr_data = [
            'src'=>$value,
            'full_src'=>oss_full_url($value),
        ];
        return $arr_data;
    }





}